<div class="depot-form-m">
  <%= error_messages_for 'client' %>
  <fieldset>
    <legend>Enter Client Details</legend>
    <% form_for :client, :builder => TaggedBuilder do |form| %>
      <table align="left" border="0">
        <tr>
          <td colspan="3">
            <%=  form.text_field :unique_id, :size=>"20px" %>
          </td>
        </tr>
        <tr>
          <td>
            <%= form.text_field("first_name", :size => "20px") %>
          </td>
          <td>
            <%= form.text_field("middle_name", :size => "20px") %>
          </td>
          <td>
            <%= form.text_field("last_name", :size => "20px") %>
          </td>
        </tr>
        <tr>
          <td>
            <%= form.text_field("spouse_first_name", :size => "20px") %>
          </td>
          <td>
            <%= form.text_field("spouse_middle_name", :size => "20px") %>
          </td>
          <td>
            <%= form.text_field("spouse_last_name", :size => "20px") %>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%= form.text_field("address1", :size => "40px") %>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%= form.text_field("address2", :size => "40px") %>
          </td>
        </tr>
        <tr>
          <td>
            <%= form.text_field("city", :size => "20px") %>
          </td>
          <td colspan="2">
            <%= form.text_field("state", :size => "20px") %>
          </td>
        </tr>
        <tr>
          <td>
            <%= form.text_field("country", :size => "20px") %>
          </td>
          <td colspan="2">
            <%= form.text_field("zip", :size => "20px") %>
          </td>
        </tr>
        <tr>
          <td>
            <%= form.text_field("home_phone", :size => "20px") %>
          </td>
          <td >
            <%= form.text_field("office_phone", :size => "20px") %>
          </td>
          <td>
            <%= form.text_field("cell_phone", :size => "20px") %>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%= form.text_field("email_address", :size => "30px") %>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%= form.text_field("spouse_contact_phone", :size => "20px") %>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%= form.text_field("spouse_email_address", :size => "30px") %>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              <label for="clientcategory_id" >Client category:</label>
              <br/>
              <%=
              @clientcategories = Clientcategory.find(:all).map { |c| [c.name, c.id]}
              form.select :clientcategory_id, @clientcategories
            %>
              <br/>
            </p>
          </td>
          <td colspan="2">
            <p>
              <label for="clientstatus_id" >Client status:</label>
              <br/>
              <%=
              @clientstatuses = Clientstatus.find(:all).map { |c| [c.name, c.id]}
              form.select(:clientstatus_id, @clientstatuses )
            %>
              <br/>
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              <label for="community_id" >Community:</label>
              <br/>
              <%=
              @communities = Community.find(:all).map { |c| [c.name, c.id]}
              form.select(:community_id, @communities )
            %>
              <%=
              observe_field :client_community_id,
                :url => {:action => "communitychanged"},
                :with => "'id=' + value"
            %>
              <%=
              hidden_field_tag("county_id_hidden", :size=>"20")
            %>
              <br/>
            </p>
          </td>
          <td colspan="2">
            <p>
              <label for="county_id" >County:</label>
              <br/>
              <%=
              @counties = County.find(:all).map { |c| [c.name, c.id]}
              form.select(:county_id, @counties)
            %>
              <br/>
            </p>
          </td>
        </tr>
        <tr>
          <td>
            <p>
              <label for="foundmode_id" >Found mode:</label>
              <br/>
              <%=
              @foundmodes = Foundmode.find(:all).map { |c| [c.name, c.id]}
              form.select :foundmode_id, @foundmodes, {:include_blank => false}
            %>
              <%=
              observe_field :client_foundmode_id,
                :url => {:action => "foundmodechanged"},
                :with => "'id=' + value"
            %>
              <br/>
            </p>
          </td>
          <td colspan="2">
            <div id="other" style="display:none">
              <%=  form.text_field :other_findmode, :size=>"20px" %>
            </div>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%=  form.text_field :contact_sales_person, :size=>"20px" %>
          </td>
        </tr>
        <tr>
          <td colspan="3">
            <%= submit_tag "Add Client" , :class => "submit" %>
          </td>
        </tr>
      </table>
    <% end %>
  </fieldset>
  <%= link_to 'Back', :action => "index" %>
</div>
<script type='text/javascript'>
<%= # Note: following javascript is run when the page is loaded.
update_page do |page|
  page[:client_county_id].disabled = true
  page[:county_id_hidden].value = @client.county_id
end
%>
</script>